﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace TFSCommon.Datasets
{
    public class MyWorkItem
    {
        public static implicit operator MyWorkItem(WorkItem wi)
        {
            return new MyWorkItem(wi);
        }

        private string state_ = null;
        private string title_ = null;
        private WorkItem wi_;

        public MyWorkItem() { }
        
        public MyWorkItem(WorkItem wi)
        {
            wi_ = wi;
        }

        public string ChangedBy { get { return wi_.ChangedBy; } }
        public string CreatedBy { get { return wi_.CreatedBy; } }
        public int Id { get { return wi_.Id; } }
        public bool IsDirty { get { return wi_.IsDirty; } }
        public string State { get { return state_ ?? wi_.State; } set { wi_.State = value; state_ = value; } }
        public string Title { get { return title_ ?? wi_.Title; } set { wi_.Title = value; title_ = value; } }

        public void Save()
        {
            wi_.Save();
        }
    }
}
